﻿using System;

namespace Validate.Net
{
    /// <summary>
    /// 一般密码校验（包含数字和字母及常规特殊符号）
    /// </summary>
    public class ValidatePwdAttribute : ValidateRegularAttribute
    {
        private static string regularStr = @"^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[!@#$\%\^\&\*\(\)])[0-9a-zA-Z!@#$\%\^\&\*\(\)]{6,16}";

        public ValidatePwdAttribute() : base(regularStr)
        { }

        public override bool Validate(object value, out string msg)
        {
            if (base.Validate(value, out msg))
                return true;
            else
            {
                msg = " 一般密码校验失败（包含数字和字母及常规特殊符号）";
                return false;
            }
        }
    }
}
